import { Controller, Get, Inject, Query } from '@nestjs/common';
import { I18nContext, I18nService } from 'nestjs-i18n';

@Controller('i18n')
export class I18nController {
  constructor(private readonly i18nService: I18nService) {}

  @Inject()
  i18n: I18nService;

  /**
   * http://127.0.0.1:3333/api/i18n/hello?lang=zh
   * http://127.0.0.1:3333/api/i18n/hello?lang=en
   * @param local
   * @returns
   */
  @Get('hello')
  getHello(): string {
    return this.i18n.t('test.hello', {
      lang: I18nContext.current()?.lang,
    });
  }
}
